package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张宇田
 * Date: 2025-08-16
 * Time: 10:35
 */
public class MyNewArray<T> {
    public Object[] arr = new Object[15];

    public T getPos(int pos){
        //存储时用 Object[]，但 取出时强制转成 T，可能导致 ClassCastException
        //return arr[pos];
        return (T)arr[pos];
    }

    public void setVal(int pos , T ob){
        arr[pos] = ob;
    }
}

class Test{
    public static void main(String[] args) {
        MyNewArray<Integer> mn = new MyNewArray<>();
        mn.setVal(1,2);
        mn.setVal(2,3);
        //mn.setVal(2,"das");

    }
}

class test3 < T extends Number > {


}
